//
//  UIView+Extensions.swift
//  SwiftDemo
//
//  Created by Chris on 2017/6/13.
//  Copyright © 2017年 chris. All rights reserved.
//

import UIKit

extension UIView {
    
    /// 获取当前view中截图
    ///
    /// - Returns: view的截图
    func cj_snapshotImage() -> UIImage {
        
        //获取Graphics大小
        UIGraphicsBeginImageContext(bounds.size)
        
        drawHierarchy(in: bounds, afterScreenUpdates: true)
        
        let image = UIGraphicsGetImageFromCurrentImageContext()
        
        UIGraphicsEndImageContext()
        
        return image ?? UIImage()
    }
}
